package com.tianqu.tms.www.permission.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;

import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.permission.controller.PermissionCreationInputController;
import com.tianqu.tms.www.permission.viewhelper.PermissionManageViewHelper;


/**
 * @author zhangxueliang
 * 权限添加入录
 */
public class PermissionCreationInputAction extends TmsAction{
	private Logger logger = Logger.getLogger(PermissionCreationInputAction.class);
	@SuppressWarnings("unchecked")
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		PermissionCreationInputController controller = new PermissionCreationInputController();
		controller.execute(uc);
		PermissionManageViewHelper viewhelper = new PermissionManageViewHelper();
		PermissionManageViewHelper viewhelper1 = (PermissionManageViewHelper)uc.getAttribute(TmsConstants.VIEWHELP);
		if(viewhelper1 != null){
			viewhelper = viewhelper1;
		}
		List userFunctionList = (List)uc.getAttribute(PermissionCreationInputController.USERFUNCTIONLIST);
		List userClassList = (List)uc.getAttribute(PermissionCreationInputController.USERCLASSLIST);
		viewhelper.setUserClassList(userClassList);
		viewhelper.setUserFunctionList(userFunctionList);
		//viewhelper.setRoleStatus(1);//默认为是
		uc.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		request.setAttribute("viewhelp", viewhelper);
		
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
